package org.jsola.hr.query;

import io.swagger.annotations.ApiParam;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.validator.constraints.Length;
import org.jsola.core.query.BaseQuery;
import org.jsola.hr.constant.*;
import org.jsola.orm.filter.Order;
import org.springframework.util.CollectionUtils;

import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import static org.jsola.core.example.BaseExample.*;
import static org.jsola.hr.example.EmpInfoExample.*;

/**
 * 员工信息
 *
 * @author zhr
 */
@EqualsAndHashCode(callSuper = true)
@Data
public class EmpInfoQuery extends BaseQuery {

    private static final long serialVersionUID = 1L;

    @ApiParam(value = N_ID, example = E_ID)
    @Length(max = 32)
    private String id;

    @ApiParam(value = N_CERTIFICATE_TYPE, example = E_CERTIFICATE_TYPE, allowableValues = CertificateTypeEnum.VALUES_STR)
    private Integer certificateType;

    @ApiParam(value = "身份证号集合" )
    private List<String> idCardList;

    @ApiParam(value = "薪资档案类型；0：未定薪 1：固定薪资档案 2：工价薪资档案" )
    private Integer salaryType;

    @ApiParam(value = "是否到岗，" )
    private Integer arrival;

    @ApiParam(value = N_EMP_AGE, example = E_EMP_AGE)
    private Integer empAge;

    @ApiParam(value = N_USER_ID, example = E_USER_ID)
    @Length(max = 32)
    private String userId;

    @ApiParam(value = N_UNION_ID, example = E_UNION_ID)
    @Length(max = 32)
    private String unionId;

    @ApiParam(value = N_PRE_JOIN_DEP, example = E_PRE_JOIN_DEP)
    @Length(max = 255)
    private String preJoinDep;

    @ApiParam(value = N_PRE_JOIN_POSITION, example = E_PRE_JOIN_POSITION)
    @Length(max = 255)
    private String preJoinPosition;

    @ApiParam(value = N_NUMBER, example = E_NUMBER)
    @Length(max = 32)
    private String number;

    @ApiParam(value = N_NAME, example = E_NAME)
    @Length(max = 50)
    private String name;

    @ApiParam(value = N_NAME_PINYIN, example = E_NAME_PINYIN)
    @Length(max = 128)
    private String namePinyin;

    @ApiParam(value = N_ID_CARD, example = E_ID_CARD)
    @Length(max = 20)
    private String idCard;

    @ApiParam(value = N_NATION, example = E_NATION)
    @Length(max = 50)
    private String nation;

    /**
     * 出生日期查询范围
     */
    @ApiParam(value = N_BIRTHDAY_START, example = E_BIRTHDAY_START)
    private String birthdayStart;
    @ApiParam(value = N_BIRTHDAY_END, example = E_BIRTHDAY_END)
    private String birthdayEnd;


    @ApiParam(value = N_GENDER, example = E_GENDER, allowableValues = GenderEnum.VALUES_STR)
    private Integer gender;

    @ApiParam(value = N_CONTRACT_SUBJECT, example = E_CONTRACT_SUBJECT)
    @Length(max = 32)
    private String contractSubject;

    @ApiParam(value = N_PHONE, example = E_PHONE)
    @Length(max = 11)
    private String phone;

    @ApiParam(value = N_EMAIL, example = E_EMAIL)
    @Length(max = 64)
    private String email;

    @ApiParam(value = N_EMP_PHOTO, example = E_EMP_PHOTO)
    @Length(max = 255)
    private String empPhoto;

    @ApiParam(value = N_HIGHEST_EDUCATION, example = E_HIGHEST_EDUCATION)
    @Length(max = 50)
    private String highestEducation;

    @ApiParam(value = N_MARITAL_STATUS, example = E_MARITAL_STATUS, allowableValues = EmpMaritalStatus.VALUES_STR)
    private Integer maritalStatus;

    @ApiParam(value = N_BIRTH_STATUS, example = E_BIRTH_STATUS, allowableValues = EmpBirthStatus.VALUES_STR)
    private Integer birthStatus;

    @ApiParam(value = N_CHANNEL_ID, example = E_CHANNEL_ID)
    @Length(max = 32)
    private String channelId;

    @ApiParam(value = N_POLITICAL_STATUS, example = E_POLITICAL_STATUS, allowableValues = EmpPoliticalStatus.VALUES_STR)
    private Integer politicalStatus;

    /**
     * 入党时间查询范围
     */
    @ApiParam(value = N_PARTY_DATE_START, example = E_PARTY_DATE_START)
    private Date partyDateStart;
    @ApiParam(value = N_PARTY_DATE_END, example = E_PARTY_DATE_END)
    private Date partyDateEnd;


    @ApiParam(value = N_PARTY_SITE, example = E_PARTY_SITE)
    @Length(max = 50)
    private String partySite;

    @ApiParam(value = N_BIRTHPLACE, example = E_BIRTHPLACE)
    @Length(max = 100)
    private String birthplace;

    @ApiParam(value = N_NATIVE_LOCATION, example = E_NATIVE_LOCATION)
    @Length(max = 100)
    private String nativeLocation;

    @ApiParam(value = N_REG_TYPE, example = E_REG_TYPE, allowableValues = RegTypeEnum.VALUES_STR)
    private Integer regType;

    @ApiParam(value = N_CURRENT_ADDR_ID, example = E_CURRENT_ADDR_ID)
    @Length(max = 32)
    private String currentAddrId;

    @ApiParam(value = N_CURRENT_LOCATION, example = E_CURRENT_LOCATION)
    @Length(max = 100)
    private String currentLocation;

    @ApiParam(value = N_COMPANY_ID, example = E_COMPANY_ID, required = true)
    @Length(max = 32)
    private String companyId;

    @ApiParam(value = N_BANK_CARD, example = E_BANK_CARD)
    @Length(max = 50)
    private String bankCard;

    @ApiParam(value = N_BANK_NAME, example = E_BANK_NAME)
    @Length(max = 100)
    private String bankName;

    @ApiParam(value = N_BANK_CARD_BRANCH, example = E_BANK_CARD_BRANCH)
    @Length(max = 255)
    private String bankCardBranch;

    @ApiParam(value = N_BANK_PLACE_ID, example = E_BANK_PLACE_ID)
    @Length(max = 32)
    private String bankPlaceId;

    @ApiParam(value = N_BANK_PLACE, example = E_BANK_PLACE)
    @Length(max = 100)
    private String bankPlace;

    @ApiParam(value = N_SOC_TYPE, example = E_SOC_TYPE)
    private Boolean socType;

    @ApiParam(value = N_IS_FIRST_SOC, example = E_IS_FIRST_SOC)
    private Boolean isFirstSoc;

    @ApiParam(value = N_SOC_CARD, example = E_SOC_CARD)
    @Length(max = 60)
    private String socCard;

    @ApiParam(value = N_IS_FIRST_PF, example = E_IS_FIRST_PF)
    private Boolean isFirstPf;

    @ApiParam(value = N_PF_CARD, example = E_PF_CARD)
    @Length(max = 50)
    private String pfCard;

    @ApiParam(value = N_HEALTH_CONDITION, example = E_HEALTH_CONDITION)
    @Length(max = 100)
    private String healthCondition;

    @ApiParam(value = N_HAS_WEIGHTY_MEDICAL_HIS, example = E_HAS_WEIGHTY_MEDICAL_HIS)
    private Boolean hasWeightyMedicalHis;

    @ApiParam(value = N_JOB_TITLE, example = E_JOB_TITLE)
    @Length(max = 50)
    private String jobTitle;

    @ApiParam(value = "标签")
    private String tag;

    /**
     * 参加工作时间查询范围
     */
    @ApiParam(value = N_JOIN_WORK_DATE_START, example = E_JOIN_WORK_DATE_START)
    private Date joinWorkDateStart;
    @ApiParam(value = N_JOIN_WORK_DATE_END, example = E_JOIN_WORK_DATE_END)
    private Date joinWorkDateEnd;


    @ApiParam(value = N_WORKING_UNIT_NAME, example = E_WORKING_UNIT_NAME)
    @Length(max = 100)
    private String workingUnitName;

    @ApiParam(value = N_PUTONGHUA_LEVEL, example = E_PUTONGHUA_LEVEL)
    @Length(max = 20)
    private String putonghuaLevel;

    @ApiParam(value = N_SPECIALITY, example = E_SPECIALITY)
    @Length(max = 255)
    private String speciality;

    @ApiParam(value = N_PRIZE_WINNING, example = E_PRIZE_WINNING)
    @Length(max = 255)
    private String prizeWinning;

    @ApiParam(value = N_ENGLISH_LEVEL, example = E_ENGLISH_LEVEL)
    @Length(max = 20)
    private String englishLevel;

    @ApiParam(value = N_NCRE_LEVEL, example = E_NCRE_LEVEL)
    @Length(max = 20)
    private String ncreLevel;

    @ApiParam(value = N_TARGET_POST, example = E_TARGET_POST)
    @Length(max = 100)
    private String targetPost;

    @ApiParam(value = N_ANNEX_ID_CARD, example = E_ANNEX_ID_CARD)
    @Length(max = 2147483647)
    private String annexIdCard;

    @ApiParam(value = N_ANNEX_HOUSEHOLD, example = E_ANNEX_HOUSEHOLD)
    @Length(max = 2147483647)
    private String annexHousehold;

    @ApiParam(value = N_ANNEX_DIPLOMA, example = E_ANNEX_DIPLOMA)
    @Length(max = 2147483647)
    private String annexDiploma;

    @ApiParam(value = N_ANNEX_DEGREE, example = E_ANNEX_DEGREE)
    @Length(max = 2147483647)
    private String annexDegree;

    @ApiParam(value = N_ANNEX_PRACTISING, example = E_ANNEX_PRACTISING)
    @Length(max = 2147483647)
    private String annexPractising;

    @ApiParam(value = N_ANNEX_MAJOR, example = E_ANNEX_MAJOR)
    @Length(max = 2147483647)
    private String annexMajor;

    @ApiParam(value = N_ANNEX_REWARD, example = E_ANNEX_REWARD)
    @Length(max = 2147483647)
    private String annexReward;

    @ApiParam(value = N_ANNEX_NO_CRIMINAL, example = E_ANNEX_NO_CRIMINAL)
    @Length(max = 2147483647)
    private String annexNoCriminal;

    @ApiParam(value = N_ANNEX_BLACK_WHITE_PHOTO, example = E_ANNEX_BLACK_WHITE_PHOTO)
    @Length(max = 2147483647)
    private String annexBlackWhitePhoto;

    @ApiParam(value = N_ANNEX_PTH_LEVEL, example = E_ANNEX_PTH_LEVEL)
    @Length(max = 2147483647)
    private String annexPthLevel;

    @ApiParam(value = N_ANNEX_ENGLISH_LEVEL, example = E_ANNEX_ENGLISH_LEVEL)
    @Length(max = 2147483647)
    private String annexEnglishLevel;

    @ApiParam(value = N_ANNEX_NCRE_LEVEL, example = E_ANNEX_NCRE_LEVEL)
    @Length(max = 2147483647)
    private String annexNcreLevel;

    @ApiParam(value = N_ANNEX_DRIVING_LICENSE, example = E_ANNEX_DRIVING_LICENSE)
    @Length(max = 2147483647)
    private String annexDrivingLicense;

    @ApiParam(value = N_ANNEX_PERSON_PHOTO, example = E_ANNEX_PERSON_PHOTO)
    @Length(max = 2147483647)
    private String annexPersonPhoto;

    @ApiParam(value = N_ANNEX_SALARY_CARD, example = E_ANNEX_SALARY_CARD)
    @Length(max = 2147483647)
    private String annexSalaryCard;

    @ApiParam(value = N_ANNEX_SOC_CARD, example = E_ANNEX_SOC_CARD)
    @Length(max = 2147483647)
    private String annexSocCard;

    @ApiParam(value = N_ANNEX_PF_CARD, example = E_ANNEX_PF_CARD)
    @Length(max = 2147483647)
    private String annexPfCard;

    @ApiParam(value = N_ANNEX_LABOR_CONTRACT, example = E_ANNEX_LABOR_CONTRACT)
    @Length(max = 2147483647)
    private String annexLaborContract;

    @ApiParam(value = N_ANNEX_ONB_RESUME, example = E_ANNEX_ONB_RESUME)
    @Length(max = 2147483647)
    private String annexOnbResume;

    @ApiParam(value = N_ANNEX_ONB_CHECKUP, example = E_ANNEX_ONB_CHECKUP)
    @Length(max = 2147483647)
    private String annexOnbCheckup;

    @ApiParam(value = N_ANNEX_LAST_LEAVE_CERT, example = E_ANNEX_LAST_LEAVE_CERT)
    @Length(max = 2147483647)
    private String annexLastLeaveCert;

    @ApiParam(value = N_ANNEX_WORK_APPLY, example = E_ANNEX_WORK_APPLY)
    @Length(max = 2147483647)
    private String annexWorkApply;

    @ApiParam(value = N_ANNEX_ADJUST_NOTICE, example = E_ANNEX_ADJUST_NOTICE)
    @Length(max = 2147483647)
    private String annexAdjustNotice;

    @ApiParam(value = N_ANNEX_PERSONAL_CHANGE, example = E_ANNEX_PERSONAL_CHANGE)
    @Length(max = 2147483647)
    private String annexPersonalChange;

    @ApiParam(value = N_ANNEX_SOC_TRANSFER, example = E_ANNEX_SOC_TRANSFER)
    @Length(max = 2147483647)
    private String annexSocTransfer;

    @ApiParam(value = N_ANNEX_PERFORMANCE_REPORT, example = E_ANNEX_PERFORMANCE_REPORT)
    @Length(max = 2147483647)
    private String annexPerformanceReport;

    @ApiParam(value = N_ANNEX_OTHER_INFOS, example = E_ANNEX_OTHER_INFOS)
    @Length(max = 2147483647)
    private String annexOtherInfos;

    @ApiParam(value = N_ANNEX_LEAVE_APPRO, example = E_ANNEX_LEAVE_APPRO)
    @Length(max = 2147483647)
    private String annexLeaveAppro;

    @ApiParam(value = N_ANNEX_LEAVE_CERT, example = E_ANNEX_LEAVE_CERT)
    @Length(max = 2147483647)
    private String annexLeaveCert;

    @ApiParam(value = N_ANNEX_LEAVE_APPLY, example = E_ANNEX_LEAVE_APPLY)
    @Length(max = 2147483647)
    private String annexLeaveApply;

    @ApiParam(value = N_ANNEX_HANDOVER_TABLE, example = E_ANNEX_HANDOVER_TABLE)
    @Length(max = 2147483647)
    private String annexHandoverTable;

    @ApiParam(value = N_SUPERVISOR, example = E_SUPERVISOR)
    @Length(max = 50)
    private String supervisor;

    @ApiParam(value = N_EMPLOY_TYPE, example = E_EMPLOY_TYPE)
    private Boolean employType;

    @ApiParam(value = N_INFORMAL_TYPE, example = E_INFORMAL_TYPE)
    private Integer informalType;

    @ApiParam(value = N_FORMAL_TYPE, example = E_FORMAL_TYPE, allowableValues = FormalTypeEnum.VALUES_STR)
    private Integer formalType;

    @ApiParam(value = N_IS_IMPROVE, example = E_IS_IMPROVE)
    private Boolean isImprove;

    @ApiParam(value = N_POST_TYPE, example = E_POST_TYPE, allowableValues = PostType.VALUES_STR)
    private Integer postType;

    @ApiParam(value = N_CONTRACTS_STATUS, example = E_CONTRACTS_STATUS, allowableValues = ContractsStatus.VALUES_STR)
    private Integer contractsStatus;

    @ApiParam(value = N_MANAGER_FORM, example = E_MANAGER_FORM)
    private Integer managerForm;

    @ApiParam(value = N_WORK_CITY_ID, example = E_WORK_CITY_ID)
    @Length(max = 32)
    private String workCityId;

    @ApiParam(value = N_WORK_CITY, example = E_WORK_CITY)
    @Length(max = 100)
    private String workCity;

    @ApiParam(value = N_JOIN_FORM_STATUS, example = E_JOIN_FORM_STATUS)
    private Boolean joinFormStatus;

    /**
     * 预计入职时间查询范围
     */
    @ApiParam(value = N_PRE_JOIN_DATE_START, example = E_PRE_JOIN_DATE_START)
    private Date preJoinDateStart;
    @ApiParam(value = N_PRE_JOIN_DATE_END, example = E_PRE_JOIN_DATE_END)
    private Date preJoinDateEnd;


    /**
     * 入职时间查询范围
     */
    @ApiParam(value = N_JOIN_DATE_START, example = E_JOIN_DATE_START)
    private Date joinDateStart;
    @ApiParam(value = N_JOIN_DATE_END, example = E_JOIN_DATE_END)
    private Date joinDateEnd;


    @ApiParam(value = N_PROBATION, example = E_PROBATION, allowableValues = ProbationEnum.VALUES_STR)
    private Integer probation;

    @ApiParam(value = N_PROBATION_DAYS, example = E_PROBATION_DAYS)
    private Integer probationDays;

    /**
     * 转正时间查询范围
     */
    @ApiParam(value = N_TURN_STRAIGHT_DATE_START, example = E_TURN_STRAIGHT_DATE_START)
    private Date turnStraightDateStart;
    @ApiParam(value = N_TURN_STRAIGHT_DATE_END, example = E_TURN_STRAIGHT_DATE_END)
    private Date turnStraightDateEnd;


    /**
     * 离职时间查询范围
     */
    @ApiParam(value = N_LEAVE_DATE_START, example = E_LEAVE_DATE_START)
    private Date leaveDateStart;
    @ApiParam(value = N_LEAVE_DATE_END, example = E_LEAVE_DATE_END)
    private Date leaveDateEnd;


    @ApiParam(value = N_LEAVE_REASON, example = E_LEAVE_REASON)
    @Length(max = 255)
    private String leaveReason;

    @ApiParam(value = N_CHANGE_STATUS, example = E_CHANGE_STATUS)
    private Integer changeStatus;

    @ApiParam(value = N_VERIFIED, example = E_VERIFIED, allowableValues = VerifiedEnum.VALUES_STR)
    private Boolean verified;

    @ApiParam(value = N_STATUS, example = E_STATUS, allowableValues = EmpInfoStatus.VALUES_STR)
    private Integer status;

    @ApiParam(value = N_APPROVAL_STATUS, example = E_APPROVAL_STATUS)
    private Integer approvalStatus;

    @ApiParam(value = N_JOIN_CITY_CODE, example = E_JOIN_CITY_CODE)
    @Length(max = 50)
    private String joinCityCode;

    @ApiParam(value = N_ARCHIVES_NUMBER, example = E_ARCHIVES_NUMBER)
    @Length(max = 80)
    private String archivesNumber;

    @ApiParam(value = N_JOIN_CITY_NAME, example = E_JOIN_CITY_NAME)
    @Length(max = 100)
    private String joinCityName;

    @ApiParam(value = N_ARCHIVES_REMAKE, example = E_ARCHIVES_REMAKE)
    @Length(max = 2147483647)
    private String archivesRemake;

    @ApiParam(value = N_RECRUIT_CHANNELS, example = E_RECRUIT_CHANNELS)
    @Length(max = 255)
    private String recruitChannels;

    @ApiParam(value = N_RETIREMENT_STATUS, example = E_RETIREMENT_STATUS)
    private Boolean retirementStatus;

    @ApiParam(value = N_RETIREMENT_DATE, example = E_RETIREMENT_DATE)
    private Date retirementDate;

    @ApiParam(value = N_RETIREMENT_REMARK, example = E_RETIREMENT_REMARK)
    @Length(max = 255)
    private String retirementRemark;

    @ApiParam(value = N_BLOOD_GROUP, example = E_BLOOD_GROUP, allowableValues = BloodGroupEnum.VALUES_STR)
    private Integer bloodGroup;

    @ApiParam(value = N_ALIPAY_ACCOUNT, example = E_ALIPAY_ACCOUNT)
    @Length(max = 50)
    private String alipayAccount;

    @ApiParam(value = N_SALARY_RULE_ID, example = E_SALARY_RULE_ID)
    @Length(max = 32)
    private String salaryRuleId;

    @ApiParam(value = N_SERVICE_FEE_RULE_ID, example = E_SERVICE_FEE_RULE_ID)
    @Length(max = 32)
    private String serviceFeeRuleId;

    /**
     * 创建时间查询范围
     */
    @ApiParam(value = N_GMT_CREATE_START, example = E_GMT_CREATE_START)
    private Date gmtCreateStart;
    @ApiParam(value = N_GMT_CREATE_END, example = E_GMT_CREATE_END)
    private Date gmtCreateEnd;


    @ApiParam(value = N_CREATE_USER_ID, example = E_CREATE_USER_ID)
    @Length(max = 32)
    private String createUserId;

    /**
     * 修改时间查询范围
     */
    @ApiParam(value = N_GMT_MODIFIED_START, example = E_GMT_MODIFIED_START)
    private Date gmtModifiedStart;
    @ApiParam(value = N_GMT_MODIFIED_END, example = E_GMT_MODIFIED_END)
    private Date gmtModifiedEnd;


    @ApiParam(value = N_MODIFIED_USER_ID, example = E_MODIFIED_USER_ID)
    @Length(max = 32)
    private String modifiedUserId;



    @ApiParam(value = "排序字段", allowMultiple=true, type="Order" ,example = "\"orders\": [{\"property\": \"userName\",\"desc\": false}]")
    private List<Order> orders;

    /**
     * 每页的条数
     */
    @ApiParam(value = "分页参数，每页的条数", example = "20")
    @Max(value = 1000, message = "pageSize不能大于1000")
    private Integer pageSize = 20;

    /**
     * 当前第几页
     */
    @ApiParam(value = "分页参数，第几页", example = "1")
    @Min(value = 1, message = "pageNo不能小于1")
    private Integer pageNo = 1;



    /**
     * 添加排序
     * @param propertyName 属性名
     * @param desc 是否降序
     * @return this
     */
    public EmpInfoQuery addOrder(String propertyName, boolean desc) {
        if (CollectionUtils.isEmpty(this.orders)) {
            this.orders = new ArrayList<>();
        }
        this.orders.add(new Order(propertyName,desc));
        return this;
    }

    @ApiParam(value = "员工工作城市code集合")
    private List<String> joinCityCodeList;

    @ApiParam(value = "员工所属公司id集合")
    private List<String> companyIdList;

    @ApiParam(value = "员工id集合")
    private List<String> empIdList;


    /**
     * 姓名或手机号或身份证号筛选
     */
    @ApiParam(value = N_NAME_OR_PHONE, example = E_NAME_OR_PHONE)
    @Length(max = 255)
    private String nameOrPhone;

    @ApiParam(value = "姓名或手机号或身份证号筛选")
    private String nameOrPhoneOrIdCard;

    @ApiParam(value = "姓名或手机号或邮箱", example = "1")
    private String nameOrPhoneOrEmail;

    /**
     * 部门ID
     */
    @ApiParam(value = N_DEP_ID, example = E_DEP_ID)
    @Length(max = 32)
    private String depId;

    /**
     * 岗位ID
     */
    @ApiParam(value = N_POSITION_ID, example = E_POSITION_ID)
    @Length(max = 32)
    private String positionId;

    @ApiParam(value = "入职管理-状态; 1:待入职 2:审批中 3:审批驳回 4:未到岗")
    private Integer approvalAndStatus;


    /**
     * 调岗时间查询范围
     */
    @ApiParam(value = "调岗开始时间", example = E_LEAVE_DATE_START)
    private Date transferDateStart;

    @ApiParam(value = "调岗截止时间", example = E_LEAVE_DATE_END)
    private Date transferDateEnd;

    @ApiParam(value = "是否展示子公司的员工,默认不展示")
    private Boolean showChildCompanyDep = false;

    @ApiParam(value = "员工的id，用来位置查询")
    private String empId;

    @ApiParam(value = "从哪一个列表进来的,1:花名册，2：员工异动（入职管理），3：员工概览" +
            "，4：转正管理，5：在职管理，6：离职管理，7：调岗管理")
    private Integer queryType;

    @ApiParam(value = "员工的id列表")
    private List<String> idList;

    @ApiParam(value = "审批通过和不需要审批的")
    private Boolean isApproPass;
}

